package com.example.tg.Service.Impl;

import com.example.tg.Dao.purchase_orderMapper;
import com.example.tg.Service.PurchaselistService;
import com.example.tg.Service.purchase_orderService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import pojo.ListPo;
import pojo.Purchase;
import pojo.PurchaseOrder;
import pojo.Xgzt;

import java.util.List;

@Service
public class purchase_orderServiceImpl implements purchase_orderService {
    @Autowired
    private purchase_orderMapper purchase_orderMapper;
    @Autowired
    private PurchaselistService purchaselistService;


    @Override
    @Transactional
    public int addPo(Purchase purchase) {
        purchase_orderMapper.addPo(purchase.getPurchaseOrder());
        purchaselistService.addPl(purchase.getList());
        return 1;
    }

    @Override
    @Transactional
    public int delePo(String  id) {
        purchase_orderMapper.delePo(id);
        purchaselistService.delePl(id);
        return 1;
    }

    @Override
    public int updaPo(PurchaseOrder purchaseOrder) {
        return purchase_orderMapper.updaPo(purchaseOrder);
    }



    @Override
    public PageInfo<PurchaseOrder> ListPo(ListPo listPo) {
        PageHelper.startPage(listPo.getPageNum(),listPo.getPageSize());
        List list=purchase_orderMapper.ListPo(listPo);
        PageInfo<PurchaseOrder> pageInfo = new PageInfo<PurchaseOrder>(list);
        return pageInfo;
    }

    @Override
    public int contPo() {
        return purchase_orderMapper.contPo();
    }

    @Override
    public List showPid() {
        return purchase_orderMapper.showPid();
    }

    @Override
    public PurchaseOrder show1Po(String pid) {
        return purchase_orderMapper.show1Po(pid);
    }



    @Override
    public int updaPo2(Xgzt xgzt) {
        return purchase_orderMapper.updaPo2(xgzt);
    }

}
